﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using _1Dot9MasterCommon;
using _1Dot9MasterBiz;
using System.Collections;

public partial class Admin_Popup_AdminUserModify : AdminBasePage
{
    private string strUserId = "";
    private string strUserName = "";
    private string strUserEmail = "";
    private string strUserPhone = ""; 

    protected void Page_Load(object sender, EventArgs e)
    {
        init();
    }

    protected void ibtnConfirm_Click(object sender, ImageClickEventArgs e)
    {
        strUserId = this.txtId.Text.Trim();      
        strUserName = this.txtName.Text.Trim();
        strUserEmail = this.txtName.Text.Trim();
        strUserPhone = this.txtPhone.Text.Trim();

        if (AdminUserInfoModify() < 1)
        {
            Response.Write("<script> alert('관리자 정보 수정 실패!'); </script>");
            return;
        }

        Response.Write("<script>parent.ClosePopup();</script>");
    }

    protected void ibtnCancel_Click(object sender, ImageClickEventArgs e)
    {
        Response.Write("<script>parent.ClosePopup();</script>");
    }

    /// <summary>
    /// 신규 어드민 유저 등록
    /// </summary>
    protected int AdminUserInfoModify()
    {
        int result = 0;
        try
        {
            using (AdminBiz adminBiz = new AdminBiz())
            {
                Hashtable htParams = new Hashtable();

                htParams.Add("@P_USER_ID", strUserId);
                htParams.Add("@P_NAME", strUserName);
                htParams.Add("@P_EMAIL", strUserEmail);
                htParams.Add("@P_PHONE", strUserPhone);

                result = adminBiz.SetAdminUserInfo(htParams);
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script> alert('" + ex.Message.ToString() + "'); </script>");
        }

        return result;
    } 
}